package proxy.jdk;

import proxy.IPerson;
import proxy.Person;
import sun.misc.ProxyGenerator;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * User:xuzhidian
 * Date:2018/4/2
 * Time:23:00
 */
public class App {
    public static void main(String[] args) throws IOException {
        IPerson person = new Person();
        IPerson instance = (IPerson) new JdkScalper().getInstance(person);
        instance.buyTicket();

        byte[] bytes = ProxyGenerator.generateProxyClass("$proxy0", new Class[]{IPerson.class});
        FileOutputStream fos = new FileOutputStream("E://$proxy0.class");
        fos.write(bytes);
        fos.flush();
        fos.close();

    }
}
